package com.wjs.spring.bean;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
//@Order(1)
public class ServiceAspect {
    @Pointcut("execution(* com.wjs.spring.bean.Service.*(..))")
    public void 通用切点(){
    }

    @Before("通用切点()")
    public void beforeService(){
        System.out.println("前置通知");
    }

    @AfterReturning("通用切点()")
    public void afterReturningService(){
        System.out.println("后置通知");
    }
    //环绕通知（范围最大的通知，前置通知之前，后置通知之后）
    @Around("通用切点()")
    public void AroundService(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕");
        joinPoint.proceed();//执行目标
        System.out.println("后环绕");
    }

    @AfterThrowing("通用切点()")
    public void AfterThrowingService(){
        System.out.println("异常通知");
    }
    @After("通用切点()")
    public void AfterService(){
        System.out.println("最终通知");
    }
}
